package org.uim.cricket.analyzer.analyze.impl;

import java.util.ArrayList;
import java.util.List;

import org.uim.cricket.analyzer.analyze.AnalyzerList;
import org.uim.cricket.analyzer.analyze.CricketMatchAnalyzable;

public class OrderedAnalyzerList implements AnalyzerList {
	
	private List<CricketMatchAnalyzable> analyzers = new ArrayList<CricketMatchAnalyzable>();
	
	@Override
	public CricketMatchAnalyzable peekAnalyzer() throws Exception {
		if (this.isEmpty()) {
			throw new Exception("Analyzer list is underflow!");
		}
		return analyzers.get(0);
	}

	@Override
	public CricketMatchAnalyzable popAnalyzer() throws Exception {
		if (this.isEmpty()) {
			throw new Exception("Analyzer list is underflow!");
		}
		CricketMatchAnalyzable temp = analyzers.get(0);
		analyzers.remove(0);
		return temp;
	}

	@Override
	public boolean isEmpty() {
		if (analyzers == null || analyzers.size() == 0) return true;
		return false;
	}

	@Override
	public boolean pushAnalyzer(CricketMatchAnalyzable itemObject) {
		analyzers.add(itemObject);
		return true;
	}

	public void setAnalyzers(List<CricketMatchAnalyzable> analyzers) {
		this.analyzers = analyzers;
	}
	
	public List<CricketMatchAnalyzable> getAnalyzers() {
		return analyzers;
	}
	
}
